var _that;
var _addCarCallBack, _buyCallBack;
// 添加购物车回调  立即购买回调
function init(target, addCarCallBack, buyCallBack) {
  _that = target,
    _addCarCallBack = addCarCallBack;
  _buyCallBack = buyCallBack;

  _that.setData({
    showbuy: false
  });
}

function showBuyDetail(goodsindex) {
  var win_hgt = wx.getSystemInfoSync().windowHeight;
  _that.setData({
    cakebuytop: win_hgt,
    showbuy: true,
    curspec: 0,
    goodsindex: goodsindex
  });

  _that.animation.top(30).step();
  _that.setData({
    ckb_amt: _that.animation.export()
  });
  //ckb_amt
}

function closeBuyDetail() {
  _that.setData({
    showbuy: false
  });
}

function addCar() {
  _that.setData({
    showbuy: false
  });
  _addCarCallBack();
}

function buy() {
  _buyCallBack();
}

function chooseSpec(e) {
  var curspec = e.currentTarget.dataset.specindex;
  _that.setData({
    curspec: curspec
  });
}

module.exports = {
  init: init,
  show: showBuyDetail,
  close: closeBuyDetail,
  addCar: addCar,
  buy: buy,
  chooseSpec: chooseSpec
}





